home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-68k-src / machines / amiga68k / libsrc / amigalib / libfreepooled.c < prev    next >
C/C++ Source or Header  |  1999-01-01  |  908b  |  34 lines

  1. #include "pool.h"
  2.  
  3. VOID LibFreePooled(POOL *poolHeader, APTR memory, ULONG memSize)
  4. {
  5.   if (SysBase->LibNode.lib_Version>=39)
  6.     return (FreePooled(poolHeader,memory,memSize));
  7.   else {
  8.  
  9.     if (poolHeader!=NULL && memory!=NULL) {
  10.  
  11.       ULONG size,*puddle=(ULONG *)((struct MinNode *)memory-1)-1;
  12.  
  13.       if (poolHeader->ThreshSize>memSize) {
  14.  
  15.         struct MemHeader *a=(struct MemHeader *)&poolHeader->PuddleList.mlh_Head;
  16.  
  17.         for(;;) {
  18.           a=(struct MemHeader *)a->mh_Node.ln_Succ;
  19.           if (a->mh_Node.ln_Succ==NULL)
  20.             return;
  21.           if (a->mh_Node.ln_Type && memory>=a->mh_Lower && memory<a->mh_Upper)
  22.             break;
  23.         }
  24.         Deallocate(a,memory,memSize);
  25.         if (a->mh_Free!=poolHeader->PuddleSize)
  26.           return;
  27.         puddle=(ULONG *)&a->mh_Node;
  28.       }
  29.       Remove((struct Node *)puddle);
  30.       size=*--puddle; FreeMem(puddle,size);
  31.     }
  32.   }
  33. }
  34.